package controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("base")
public class ItemController {
	private List<String> items=new Vector<String>();
	public ItemController() {
		items.add("abc");
		items.add("bcd");
		items.add("xyz");
	}
	@GetMapping("findAllItems")
	public String findAllItems(Model model) {
		model.addAttribute("items",this.items);
		return "showAllItems";
	}
	
	@GetMapping("deleteItem")
	public String deleteItem(int index) {
		items.remove(index);
		return "forward:findAllItems";
	}
}
